//
//  NetWorkConfig.swift
//  TeaShop
//
//  Created by 刘泽 on 2018/1/14.
//  Copyright © 2018年 刘泽. All rights reserved.
//

import UIKit
import Moya
import Alamofire
import Foundation
@_exported
import SSBaseTool

public func defaultAlamoFireManager() -> Manager {



    let configuration = URLSessionConfiguration.default
    configuration.timeoutIntervalForRequest = 10 //网络超时时间
    configuration.timeoutIntervalForResource = 10
    configuration.httpAdditionalHeaders = Alamofire.SessionManager.defaultHTTPHeaders
    
    let policies: [String: ServerTrustPolicy] = [
        "ap.grtstar.cn": .disableEvaluation
    ]
    let manager = Alamofire.SessionManager(configuration: configuration, serverTrustPolicyManager: ServerTrustPolicyManager(policies: policies))
    
    manager.startRequestsImmediately = false
    
    return manager
}

public func endpointMapping<Target:TargetType>(target: Target) -> Endpoint {

//    log.info("请求连接：\(target.baseURL)\(target.path) \n方法：\(target.method)\n请求头:\(String(describing: target.headers))\n参数：\(target.task)")
    return MoyaProvider.defaultEndpointMapping(for: target)
}
